home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / pgm_util / sealit / wizard / foo / winapi.bas < prev   
Encoding:
BASIC Source File  |  1995-12-04  |  1.3 KB  |  29 lines

  1. Option Explicit
  2.  
  3. Type rect
  4.     left As Integer
  5.     top As Integer
  6.     right As Integer
  7.     bottom As Integer
  8. End Type
  9.  
  10. Global Const SM_CYSCREEN = 1
  11. Global Const SM_CXSCREEN = 0
  12. Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As Integer
  13. 'Declare Function openfile Lib "Kernel" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As Integer
  14. Declare Sub GetWindowRect Lib "User" (ByVal hWnd As Integer, lpRect As rect)
  15. Declare Sub OffsetRect Lib "User" (lpRect As rect, ByVal x As Integer, ByVal y As Integer)
  16. Declare Sub MoveWindow Lib "User" (ByVal hWnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer)
  17. Declare Function WinExec Lib "Kernel" (ByVal lpCmdLine As String, ByVal nCmdShow As Integer) As Integer
  18. Global Const SW_SHOW = 5
  19.  
  20.  
  21. Sub CenterPopUpWindow (frm As Form)
  22.     'CenterPopUpWindow take the window handle and centers the dialog box
  23.     Dim void%, lpRect As rect
  24.     GetWindowRect frm.hWnd, lpRect
  25.     OffsetRect lpRect, -lpRect.left, -lpRect.top
  26.     MoveWindow frm.hWnd, ((GetSystemMetrics(SM_CXSCREEN) - lpRect.right) / 2), (GetSystemMetrics(SM_CYSCREEN) - lpRect.bottom) / 2, lpRect.right, lpRect.bottom, 0
  27. End Sub
  28.  
  29.